home *** CD-ROM | disk | FTP | other *** search
/ Light ROM 1 / LIGHT-ROM 1 (Amiga Library Services)(1994).iso / ffdisks / d886.lha / PatchLibrary / CPUClr.asm < prev    next >
Assembly Source File  |  1993-07-16  |  4KB  |  170 lines

  1. ;
  2. ; CPUClr - (C) 1993 Stefan Fuchs
  3.  
  4. ;replaces BltClear() with a CPU based function
  5. ;compatible to kick V36's "fill" feature 
  6.  
  7.     include exec/types.i
  8.     include ASMMacros.i
  9.  
  10.  
  11. InstallPatch    = -30    ;patch
  12. WaitRemovePatch    = -36
  13. FindPatch    = -48
  14.  
  15. ;----------------------------------------
  16. Main:
  17.     OPENLIB DosName,0,DosFailed    ;Open Dos Library
  18.     move.l d0,DosBase
  19.  
  20.     lea.l head(pc),a0        ;Print Title Text
  21.     bsr TextOutput
  22.  
  23.     OPENLIB PatchName,0,PatchFailed    ;Open Patch Library
  24.     move.l d0,PatchBase
  25.  
  26.     lea.l IdString(pc),a0        ;Is Patch Installed
  27.     CALL FindPatch,PatchBase
  28.     tst.l d0
  29.     beq install            ;No ->install
  30.  
  31.     move.l d0,a0            ;Remove Patch
  32.     CALL WaitRemovePatch
  33.     lea.l RemoveText(pc),a0
  34.     tst.l d0
  35.     beq exit
  36.     lea.l RemoveFailText(pc),a0
  37.     bra exit
  38.  
  39. install:
  40.     lea.l NewPatch(pc),a0
  41.     CALL InstallPatch
  42.     lea.l InstalledText(pc),a0
  43.     tst.l d0
  44.     bne exit
  45.     lea.l InstallFailText(pc),a0
  46.  
  47. exit:
  48.     bsr TextOutput
  49.     CLOSELIB PatchBase        ;Close patch Library
  50.  
  51. PatchFailed:
  52.     tst.l PatchBase
  53.     bne PatchFailedSkip
  54.     lea.l ReqPatchLib(pc),a0
  55.     bsr TextOutput
  56.  
  57. PatchFailedSkip:
  58.     CLOSELIB DosBase        ;Close Dos Library
  59. DosFailed:
  60.     rts
  61. ******************************************************************V1.3*
  62. * Name:        TextOutput
  63. * Function:    Writes a C-string to std output (CLI,PRT,...)
  64. * Version:    V1.2    (works)
  65. * Assembler:    MasterSeka V1.75 & OMA V1.81
  66. * Copyright:    1991 Stefan Fuchs
  67. *
  68. * Inputs:    a0 = Pointer to a C-string
  69. * Assumptions:    DosBase
  70. * Results:    
  71. * Destroyed registers:
  72. * Code:        pc-relative
  73. * Known bugs:    
  74. * See also:    
  75. * Notes:    Exits without any output,
  76. *        if the Outputhandle or a0 is null
  77. ***********************************************************************
  78. TextOutput:
  79.     movem.l d0-d3/a0/a1/a6,-(sp)
  80.     moveq.l #0,d3
  81.     move.l a0,d2
  82.     beq.s TextOutputExit
  83. TextOutputLoop:
  84.     addq.l #1,d3
  85.     tst.b (a0)+
  86.     bne.S TextOutputLoop
  87.     lea DosBase(pc),a0
  88.     move.l (a0),a6
  89.     jsr -60(a6)    ;OutPut
  90.     move.l d0,d1
  91.     beq.s TextOutputExit
  92.     jsr -48(a6)    ;Write
  93. TextOutputExit:
  94.     movem.l (sp)+,d0-d3/a0/a1/a6
  95.     rts
  96. ;-------------------------------------------------
  97.     dc.b    "$VER: CpuClr 2.5 (16.02.1993)",0
  98. GfxName:    dc.b "graphics.library",0
  99. DosName:    dc.b "dos.library",0
  100. PatchName:    dc.b "patch.library",0
  101. IdString:    dc.b "CPUCLR0",0
  102. head:        dc.b $9b,"1mCPUCLR V2.5 ",$9b,"0m (C) 1993 by Stefan Fuchs",10,0
  103. ReqPatchLib:    dc.b "*** Requires patch.library in libs:",10,0
  104. InstalledText:    dc.b "Patch successfully installed",10,0
  105. InstallFailText:dc.b "*** Failed to install patch",10,0
  106. RemoveText:    dc.b "Patch successfully removed",10,0
  107. RemoveFailText:    dc.b "*** Failed to remove patch",10,0
  108.  
  109.     even
  110. DosBase:    dc.l 0
  111. PatchBase:    dc.l 0
  112.  
  113. NewPatch:
  114.     dc.l NewBltClr            ;pointer to the patch code to be installed
  115.     dc.l NewBltClrEnd-NewBltClr    ;optional length of NPAT_NewCode in bytes
  116.     dc.l GfxName            ;pointer to the LibraryName
  117.     dc.w 0                ;version of Library to open
  118.     dc.w -300            ;LVO of function to patch
  119.     dc.w 0                ;Priority (-127...+126) of the patch
  120.     dc.w 0                ;currently none defined (keep zero)
  121.     dc.l IdString            ;optional pointer to an IDString
  122.     dc.l 0                ;optional pointer to longword for Result2
  123.  
  124. ;-----------------------------------------------
  125. NewBltClr:
  126. ;this is the new bltclear() routine
  127. ;must be pc-relative
  128. ;A1= &memBlock
  129. ;D0= bytecount
  130. ;D1= flags
  131.  
  132.     move.l    d2,a0
  133.     btst    #1,d1
  134.     beq    NewBltClrSkip1    ;calc size
  135.     move.l    d0,d2
  136.     swap     d2
  137.     mulu    d2,d0
  138.  
  139. NewBltClrSkip1:            ;ByteSize now in d0
  140.     moveq    #0,d2
  141.     btst    #2,d1
  142.     beq    NewBltClrSkip2
  143.     move.l  d1,d2
  144.     swap    d1        ;d1 is no longer correct
  145.     move.w    d1,d2
  146.     tst.l    d0
  147.     beq    NewBltClrExit    ;Copy size is zero ->better exit
  148.  
  149. NewBltClrSkip2:            ;fillpatten now in d2
  150.     btst    #1,d0        ;Is Bytesize a multible of 4
  151.     beq NewBltClrSkip3    ;Yes than skip this
  152.     move.w    d2,(a1)+
  153.     subq.l    #2,d0
  154.     beq     NewBltClrExit
  155.  
  156. NewBltClrSkip3:
  157.     lsr.l    #2,d0
  158.     subq.l    #1,d0
  159.  
  160. ClearLoop:
  161.     move.l    d2,(a1)+
  162.     dbra d0,ClearLoop
  163.  
  164. NewBltClrExit:
  165.     move.l    a0,d2
  166.     rts
  167. NewBltClrEnd:
  168.  
  169.     END
  170.